import { Component, Vue, Inject } from 'vue-property-decorator';

import { IRoomRentBasic } from '@/shared/model/room-rent-basic.model';
import RoomRentBasicService from './room-rent-basic.service';
import AlertService from '@/shared/alert/alert.service';

@Component
export default class RoomRentBasicDetails extends Vue {
  @Inject('roomRentBasicService') private roomRentBasicService: () => RoomRentBasicService;
  @Inject('alertService') private alertService: () => AlertService;

  public roomRentBasic: IRoomRentBasic = {};

  beforeRouteEnter(to, from, next) {
    next(vm => {
      if (to.params.roomRentBasicId) {
        vm.retrieveRoomRentBasic(to.params.roomRentBasicId);
      }
    });
  }

  public retrieveRoomRentBasic(roomRentBasicId) {
    this.roomRentBasicService()
      .find(roomRentBasicId)
      .then(res => {
        this.roomRentBasic = res;
      })
      .catch(error => {
        this.alertService().showHttpError(this, error.response);
      });
  }

  public previousState() {
    this.$router.go(-1);
  }
}
